//
//  UIView+NEDForm.m
//  NEDFormView_Example
//
//  Created by 000 on 2022/1/9.
//  Copyright © 2022 000. All rights reserved.
//

#import "UIView+NEDForm.h"

@implementation UIView (NEDForm)

- (void)form_corner:(float)corner pos:(UIRectCorner)corners{
    if(CGRectIsEmpty(self.bounds)){
        [self layoutIfNeeded];
    }
    if (CGRectIsEmpty(self.bounds)) {
        self.layer.cornerRadius = corner;
        [self.layer setMasksToBounds:YES];
        return;
    }
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(corner, corner)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.bounds;
    maskLayer.path = maskPath.CGPath;
    self.layer.mask = maskLayer;
}

- (void)form_cornerNone{
    if(!self.layer.mask){
        return;
    }
    self.layer.mask = nil;
}

@end
